package cn.uexpo.lhz.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import cn.uexpo.lhz.biz.TUserService;
import cn.uexpo.lhz.plus.PageUtils;
import cn.uexpo.lhz.plus.R;
import cn.uexpo.lhz.domain.TUserEntity;
import cn.uexpo.lhz.plus.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 *
 *
 * @author xiaohuai
 * @email 1477227147@gmail.com
 * @date 2020-08-26 16:23:30
 */
@RestController
@RequestMapping("cert/tuser")
public class TUserController {
    @Autowired
    private TUserService tUserService;



    @GetMapping("/listA")
    public List<Integer> listA(){
        System.out.println("远程");
       List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(i);
        }
        return list;
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("coupon:tuser:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tUserService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{tId}")
    public R info(@PathVariable("tId") Long tId){
		TUserEntity tUser = tUserService.getById(tId);

        return R.ok().put("tUser", tUser);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TUserEntity tUser){
		tUserService.save(tUser);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("coupon:tuser:update")
    public R update(@RequestBody TUserEntity tUser){
		tUserService.updateById(tUser);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("coupon:tuser:delete")
    public R delete(@RequestBody Long[] tIds){
		tUserService.removeByIds(Arrays.asList(tIds));

        return R.ok();
    }

}
